<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
	com.ba360.portal.database.dbo.User user = (com.ba360.portal.database.dbo.User)session.getAttribute("USER");
	if (user==null)
	{
	request.setAttribute("USER_NOT_LOGGED_IN","UNPLUGGED");
	%>
	
	<jsp:forward page="/portal/login.do"/>
	
	<%}%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>droik.com</title>
<META NAME="Classification" lang="en-us" CONTENT="Classifeds,Realestate,News,News and Information,Internet Daily,Daily News,Web Magazine,E-Zine,Local Portal,Internet Newspaper">
<META NAME="Description" CONTENT="Pune360.com is Pune's most comprehensive webportal. It's got Classifieds, RealEstate, News, Events and also a Writing Wall(Editorial). Watch this site Pune.">
<META NAME="Keywords" lang="en-us" CONTENT="Pune real estate,Pune,Pune classifieds,Pune city,Poona,Pune online,virtual pune,virtualpune,Punyanagari,Oxford of the East,Pune news,Pune maharashtra,Pune India,Pimpri,Chinchwad,Bhosari,Kondhwa,Wakad,hingewadi,hingewadi real estate,Pune University,PICT,COEP,Pratapgad,Raigad,Sinhagad,Karla Caves,Bhaja,Lonavala,National Defence Academy,NDA,Marathi,Maharashtrian,Peshwa,Chapekar,Aga Khan Palace,Shaniwarwada,Mahabaleshwar,Lokmanya Tilak,Panchgani,Pune Festival,Ganesh,Ganapati,Dagdusheth,Sawai Gandharva,Raja Kelkar Museum,Sarasbaug,Shivaji">
<META HTTP-EQUIV="KEYWORDS" CONTENTS="Pune real estate,Pune,Pune classifieds,Pune city,Poona,Pune online,virtual pune,virtualpune,Punyanagari,Oxford of the East,Pune news,Pune maharashtra,Pune India,Pimpri,Chinchwad,Bhosari,Kondhwa,Wakad,hingewadi,hingewadi real estate,Pune University,PICT,COEP,Pratapgad,Raigad,Sinhagad,Karla Caves,Bhaja,Lonavala,National Defence Academy,NDA,Marathi,Maharashtrian,Peshwa,Chapekar,Aga Khan Palace,Shaniwarwada,Mahabaleshwar,Lokmanya Tilak,Panchgani,Pune Festival,Ganesh,Ganapati,Dagdusheth,Sawai Gandharva,Raja Kelkar Museum,Sarasbaug,Shivaji">

<link href="../css/sample1.css" rel="stylesheet" type="text/css">

<!--script type="text/javascript" src="../scripts/prototype.js"></script>
<script type="text/javascript" src="../scripts/lightbox.js"></script>
<link rel="stylesheet" href="../css/default.css" media="screen,projection" type="text/css" />
<link rel="stylesheet" href="../css/lightbox.css" media="screen,projection" type="text/css" /-->
 
<style type="text/css">
	<!--
	body 
	{
		background-image: url(../images/main_bg2.gif);
	}
		.style2 {color: #88DB23}
		.style3 {color: #FFFFFF}
	-->
</style>
<script>
	function cityaction()
	{
	var selObj = document.getElementById('cities');
	var selIndex = selObj.selectedIndex;
	document.getElementById('city_id').value=selObj.options[selIndex].value;
	document.getElementById('City').value=selObj.options[selIndex].text;	
	 if(selObj.options[selIndex].value == "9")
	 {
	 	document.getElementById('other').value="";
	 	document.getElementById('othercity').style.display = "block";
	 }
	 else
	 {
	  document.getElementById('other').value="";
	  document.getElementById('othercity').style.display = "none";
	 }
	}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<jsp:include page="top.jsp"/>
<br>
<table width="720" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td><img src="../images/classifieds_tab.gif" width="720" height="76" border="0" usemap="#Map" href="../portal/index.do"></td>
	</tr>
	<tr>
		<td background="../images/border_bg2.gif">
			<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr> 
					<td colspan="5">
					     <%
						String choice = request.getParameter("Action");
						
						if (choice!=null && choice.equals("Next"))
						{
							String postingType = request.getParameter("PostingType");
							request.setAttribute("category_id",postingType);
							String catType     = request.getParameter("CatType");	
							String city 	   = request.getParameter("city");
							String other 	   = request.getParameter("other");
							if (postingType==null || postingType.equals("0"))
							{
								request.setAttribute("Error","Posting type not selected");
							}
							else if( (city.equals("9")) && (other.equals("") || other.equals(null)))
							{
								request.setAttribute("Error","Other city cannot be empty");
							}
							else if (city==null || city.equals(""))
							{
								request.setAttribute("Error","City not selected");
							}
							else if (postingType!=null && !postingType.equals("0") && city!=null && !city.equals(""))
							{						
							String url = "../portal/postadv.do?category_id="+postingType+"&CatType="+catType+"&City="+city;	
					     %>
							<jsp:forward page="<%=url%>"/>
					     <%		}
					        } 
					        else if (choice!=null && choice.equals("Cancel"))
						{
					     %>
							<jsp:forward page="../portal/myadlist.do"/>
					     <% }
					     %>
					     
					     <%						
						java.sql.Connection conn = null;
						java.sql.Statement  stat = null;
						Class.forName( "com.mysql.jdbc.Driver");
						conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/ba3602_droikclassifieds","ba3602_portal","p0rtal" );
						//conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/ba3602_droikclassifieds","root","" );
						stat = conn.createStatement();						
					     %>
      					     <form name="form1" method="get" action="../portal/NewAdv.do">
						<table border="0" cellpadding="3" cellspacing="1" width="100%" class="text">
							<tr> 
								<td valign="middle" colspan="6" class="title">
									<div align="center"><img src="../images/step1.gif" width="646" height="32"><font color="#CCCCCC"><br>
										<br>
										</font>
									</div>
								</td>
							</tr>
							
							<tr> 
								<td valign="top" colspan="6"> 
									<% if (request.getAttribute("Error")!=null)
									   {
										out.println(request.getAttribute("Error"));	
									   }
									%>
								</td>
							</tr>
							
							<tr> 
								<td valign="top" class="label" width="27%"> 
									<div align="right">Posting Type:</div>
								</td>
								<td valign="top" colspan="5"> 
									<select name="PostingType" onChange="javascript:submit()">
										<%		  
											java.sql.ResultSet rs = stat.executeQuery("select name,category_id  from categories where par_category_id is null;");
											String postingType = request.getParameter("PostingType");
											int postingID=0;
											
											if (postingType!=null && postingType.length()>0 && !postingType.equals("0"))
											{
												postingID = Integer.parseInt(postingType);
											} 
											else 
											{
										%>
												<option value="0" selected>--Select a Category--</option>
										<%	}
											while (rs.next())
											{
												String name = rs.getString(1);
												int id = rs.getInt(2);
										%>
										<%
											if (id==postingID )
											{
												out.println(name +"  "+postingType);
										%>
												<option value="<%=id%>" selected><%=name%></option>
										<%	}
										        else 
										        {
										%>
												<option value="<%=id%>"><%=name%></option>
										<%
											}
										} 
										%>
									</select>
								</td>
							</tr>

							<tr> 
								<td valign="top" class="label" width="27%"> 
									<div align="right">Sub Category Type:</div>
								</td>
								
								<td valign="top" colspan="5"> 
									<% if (postingID==0)
									   {
									%>
										<select name="CatType" onChange="javascript:submit()" disabled='true'>
									<% }
									%>
									<% if (postingID!=0)
									   {
									%>
									   	<select name="CatType" onChange="javascript:submit()">
									<%
											rs = stat.executeQuery("select name,category_id  from categories where par_category_id ="+postingID);
											String subcategory_id = request.getParameter("CatType");
											int subidCat=0;
											
											if (subcategory_id!=null)
											{
												subidCat = Integer.parseInt(subcategory_id);
											}
											while (rs.next())
											{
												String subname = rs.getString(1);
												int subid = rs.getInt(2);
									
									%>
									<%
												if (subid==subidCat )
												{
									%>
													<option value="<%=subid%>" selected><%=subname%></option>
									<%			}
											        else
											        {
									%>
													<option value="<%=subid%>"><%=subname%></option>
									<%
												}
											}
									    }	
									%>
									</select>
								</td>
							</tr>

							<tr> 
								<td valign="top" class="label" width="27%"> 
									<div align="right">City:</div>
								</td>
								<td valign="top">									
									<%							
							if (postingID==0)
         						   {         						   
         						%>
         						     <select name="city" id="cities" onChange="cityaction()" disabled='true'>         						     
         						<% }    
         						   else
         						   {  
         						  
         						    %>
         						     <select name="city" id="cities" onChange="cityaction()">         						     
         						<% }          													   
	         						   rs = stat.executeQuery("select city_id,cityname from lookup_city"); 
	         						   
	         						   while (rs.next())
	         						   {         		
		         						   int cityid = rs.getInt(1);
									   String cityname = rs.getString(2);
									   			      						   
         						%>
	         								<option value="<%=cityid%>"><%=cityname%></option>
	         					<%
	         						   }	         						    
	         					%>		
         						    </select>
         						    
         						    <td>         
         						          <input type="hidden" name="city_id" id="city_id" value=""/>						    	
         						          <input type="hidden" name="City" id="City" value=""/>						    	
         						    	  <span id="othercity" style="display:none">Other city :<Input type="text" name="other" id="other" value="" /></span>         						    	
         						    </td>
								</td>
							</tr>
                
							<tr> 
								<td width="27%"></td>
								<td width="13%"></td>
								<td width="16%"></td>
								<td width="8%"></td>
								<td width="20%"></td>
								<td width="16%"></td>
							</tr>
							
							<tr> 
								<td colspan="6"> 
									<div align="center">
										<input type="hidden" name="isedit" value="false">									
										<input type="submit" name="Action" value="Cancel" class="button">
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 
										<input type="submit" name="Action" value="Next" class="button">
									</div>
								</td>
							</tr>
              					</table>
					     </form>
      						<%conn.close();%>
    
		  			</td>
        			</tr>
      			</table>
    		</td>
  	</tr>
  	
	<tr>
		<td>
			<img src="../images/border_bot2.gif" width="719" height="20">
		</td>
	</tr>
</table>
 <br>
 <br>
<jsp:include page="../jsp/footer.html"/>
<jsp:include page="../jsp/map.html"/>

</body>
</html>
